<?php
class Model_ageinfo extends CI_Model{
	protected $_table = "tbl_cruises";
	protected $_cruise = "tbl_sheep";
	protected $_user = "tbl_user";
	public function __construct(){
		parent::__construct();
		$this->load->database();
	}
	public function count_all(){
		$this->db->join("tbl_sheep","tbl_sheep.sheep_id = tbl_cruises.cruiseid");
		$this->db->join("tbl_user","tbl_user.user_id = tbl_cruises.agencyid");
		return $this->db->count_all_results($this->_table);
	}
	public function listall(){
		$this->db->join("tbl_sheep","tbl_sheep.sheep_id = tbl_cruises.cruiseid");
		$this->db->join("tbl_user","tbl_user.user_id = tbl_cruises.agencyid");
		$this->db->order_by("tbl_cruises.id","DESC");
		return $this->db->get($this->_table)->result_array();
	}
	public function getdata($id){
		$this->db->where("id",$id);
		return $this->db->get($this->_table)->row_array();
	}
	public function getuser($id){
		$this->db->where("user_id",$id);
		return $this->db->get($this->_user)->row_array();
	}
	public function update($id,$data){
		$this->db->where("id",$id);
		$this->db->update($this->_table,$data);
	}
	public function updatecrui($id,$data){
		$this->db->where("sheep_id",$id);
		$this->db->update($this->_cruise,$data);
	}
	public function del($id){
		$this->db->where("id",$id);
		$this->db->delete($this->_table);
	}
}